﻿--[[
   @brief    sys setting dialog
   @author   hqzheng
   @version  1.0
   @date     2017-05-024
--]]

setting_dialog_view =
{
    ierd_tgp.tpf_ui.Require("TPFLocalization.lua");

    dialog_ptr = nil;
    dialog_id = 0;
    
    normal_color = 8223093;--0x7d7975
    error_color = 2302884; --0x2323A4
    succ_color = 8453888; --0x80ff00
    
    ------------------------------------------------------------------
    --常规设置控件
    auto_start_checkbox = nil;
    auto_login_checkbox = nil;
    auto_hidde_checkbox = nil;
    anchor_subscribe_checkbox = nil;
    video_subscribe_checkbox = nil;
    mini_wnd_when_close_wnd_checkbox = nil;
    exit_wnd_when_close_wnd_checkbox = nil;
    mini_wnd_when_start_game_checkbox = nil;
    keep_wnd_when_start_game_checkbox = nil;
    open_game_list_cloud_sync_checkbox = nil;
    open_wegame_silent_update_checkbox = nil;
    app_inner_screenshot_combobox = nil;
    open_page_cache_setting_checkbox = nil;
    open_page_preload_checkbox = nil;
    router_accelerate_setting_checkbox = nil;
    after_buy_game_oper_checkbox = nil;
    subscribe_after_open_download_checkbox = nil;

    open_wegame_silent_update_warning_tips = nil;
    open_wegame_silent_update_warning_tips_show = false;
    dpi_setting_checkbox = nil;
    
    
    game_streaming_tab_container = nil;
    game_streaming_tab_button = nil;
    game_streaming_enable_checkbox = nil;
    game_streaming_enable_warning_tips = nil;
    game_streaming_password_checkbox = nil;
    game_streaming_password_edit = nil;
    game_streaming_password_len_limit_tips = nil;
    
    game_linker_qrcode = nil;
    game_linker_ip_text = nil;
    game_linker_pc_name = nil;
    game_linker_account_name = nil;
    game_linker_pc_name_tip = nil;
    game_linker_enable = nil;
    game_linker_disable = nil;
    
    ------------------------------------------------------------------
    --游戏下载设置控件
    download_path_edit = nil;
    tips_for_download_dir = nil;
    
    install_path_edit = nil;
    tips_for_install_dir = nil;
    
    install_path_mgr_cnt = nil;
    install_path_1 = nil;
    install_path_2 = nil;
    install_path_3 = nil;
    install_path_space_1 = nil;
    install_path_space_2 = nil;
    install_path_space_3 = nil;
    install_path_count = nil;

    current_query_space_tip_id = 0;
    
    auto_download_checkbox = nil;
    router_download_checkbox = nil;
    
    anchor_subscribe_flag = 1;
    video_subscribe_flag = 1;
    --checkbox group
    no_speed_limit_checkbox = nil;
    have_speed_limit_checkbox = nil;
    speed_input_edit = nil;
    --checkbox group
    save_delete_checkbox = nil;
    save_7days_checkbox = nil;
    save_forever_checkbox = nil;

    ------------------------------------------------------------------
    -- Debug控件
    anti_addiction_checkbox = nil;
    detail_log_checkbox = nil;
    select_game_duration_combox = nil;
    game_id_combox = nil;
    game_duration_tips = nil;

    ---------------------------------------------------------------
    tab_exclude_ctrl = nil; --Excluder_ForTabSwitch
    open_reason = 0;
    tab_page = 0;
    apply_button = nil;
    --
    is_setting_change = false;
    cfg_table = {};
    
    is_flash_ui_complete = true;
    ---------------------------------------------------------------
    is_netbar = 0;      -- 是否网吧环境
    is_dev_client = false;
    developer_game_list = nil;

    qos_track_settings = {};
    locales_list = nil;

    --[[
        游戏截图快捷键
        alt+2:18+50
        alt+f12:18+123
        alt+x：18+88
        Printscreen：44
    ]]
    screenshot_cfg_vlaue_list = {"18+50", "18+123", "18+88", "44"};

    init = function()
        setting_dialog_view.inner_log("setting_dialog_view init.");
        setting_dialog_view.get_netbar_flag();
        local game_lib =
            base_utility.get_component_adapter("IGame_library",
                "ierd_tgp.game_library.Get_game_library_adapter();");
        ierd_tgp.tpf_ui.Require("install_path_mgr\\control.lua");
        setting_dialog_view.is_dev_client = game_lib ~= nil and game_lib:Is_Develop_ver();
        setting_dialog_view.locales_list = ierd_tgp.tpf_ui.LocaleNameList:new();
    end;

    get_netbar_flag = function()
        local game_lib =
            base_utility.get_component_adapter("IGame_library",
                "ierd_tgp.game_library.Get_game_library_adapter();");
        setting_dialog_view.is_netbar = game_lib:get_bind_channel_id();    
        setting_dialog_view.inner_log("[setting_dialog_view]netbar: %d.", setting_dialog_view.is_netbar);
    end;

    inner_log = function (msg, core_msg)
        base_utility.log(string.format("[setting_dialog_view] %s", msg), core_msg);
    end;
    
    show = function(json_str)
        setting_dialog_view.inner_log("setting_dialog_view show");
        
        setting_dialog_view.dialog_ptr = ui_utility.get_ctrl_ptr_by_id(setting_dialog_view.dialog_id);


        if nil == setting_dialog_view.dialog_ptr then
            setting_dialog_view.create_dialog();
            setting_dialog_view.set_dialog_height();
            setting_dialog_view.get_ui_control();
        end;
        
        if setting_dialog_view.dialog_ptr then 
            if setting_dialog_view.dialog_ptr:IsVisible() == TRUE then--打开后再次打开
                setting_dialog_view.dialog_ptr:BringToTop();
            else--关闭后打开
                setting_dialog_view.dialog_ptr:Show(TRUE);
                setting_dialog_view.dialog_ptr:BringToTop();
                --先切换，在load cfg
                setting_dialog_view.switch_tabl(json_str);        
                setting_dialog_control.get_setting_config_req();
            end;
        end;

       local oss_gamestreaming = comm_center.call_service("Svr_GameStreaming_Enable_OSSGameStreaming", {});
       -- if  oss_gamestreaming ~=nil  and oss_gamestreaming.is_enable ~= nil and oss_gamestreaming.is_enable then
            local game_linker_tab = ui_utility.get_ctrl_id_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\ButtonGroup\\BtnGameLinker");
            if game_linker_tab ~= nil then
                ui_utility.setproperty_by_id(game_linker_tab,  "Visible", "true");
            end
        --end
        
    end;
    
    
    --确定按钮执行
    ok = function(uilib, dwClickId)
        if base_utility.CLIENT_TYPE.OVERSEA_VER ==  base_utility.get_client_version_type() or 
                     setting_dialog_view.is_dev_client == true then
            if setting_dialog_view.deal_lanuage_change() == true then
                return;
            end
        end
        setting_dialog_view.save_cfg();
        setting_dialog_view.close(0,0);
    end;
    
    save_cfg = function()
        local new_cfg_tbl = setting_dialog_view.get_cfg_from_ui();
        for k, v in pairs(new_cfg_tbl) do 
            --setting_dialog_view.inner_log("save_cfg before, key:"..k..",  value:"..setting_dialog_view.cfg_table[k]);
            setting_dialog_view.cfg_table[k] = v;
            --setting_dialog_view.inner_log("save_cfg after,  key:"..k..",  value:"..setting_dialog_view.cfg_table[k]);
        end;
        setting_dialog_control.set_setting_config(setting_dialog_view.cfg_table);
        setting_dialog_control.set_subscribe_after_open_dl_cfg(
            setting_dialog_view.cfg_table["subscribe_after_open_download"]);
    end;
    -----------------------------------------------------
    unsignaled = function(uilib, dwClickId)
        if setting_dialog_view.is_flash_ui_complete == true then
            setting_dialog_view.inner_log("setting_dialog_view unsignaled id:"..dwClickId);
            -- 静默升级修改提示
            setting_dialog_view.check_unset_silent_update_show_tips();
            setting_dialog_view.check_all_setting();
        end;
          if nil ~= setting_dialog_view.game_streaming_password_checkbox and 
        nil ~= setting_dialog_view.game_streaming_password_edit then
            setting_dialog_view.game_streaming_password_edit:Enable(setting_dialog_view.game_streaming_password_checkbox:IsChecked());
            if setting_dialog_view.game_streaming_password_checkbox:IsChecked() == FALSE then 
                setting_dialog_view.game_streaming_password_len_limit_tips:Show(FALSE);
            end;
        end;
        
        if nil ~= setting_dialog_view.game_streaming_enable_checkbox and
        nil ~= setting_dialog_view.game_streaming_enable_warning_tips then
            setting_dialog_view.game_streaming_enable_warning_tips:Show(setting_dialog_view.game_streaming_enable_checkbox:IsChecked());
            setting_dialog_view.game_streaming_password_checkbox:Enable(setting_dialog_view.game_streaming_enable_checkbox:IsChecked());
            if setting_dialog_view.game_streaming_password_checkbox:IsChecked()  == TRUE and 
                setting_dialog_view.game_streaming_enable_checkbox:IsChecked()  == TRUE then
                setting_dialog_view.game_streaming_password_edit:Enable(TRUE);
                if setting_dialog_view.game_streaming_password_checkbox:IsChecked() == TRUE then
                local password_text = setting_dialog_view.game_streaming_password_edit:GetText();
                local u8str = CUIStrtoU8(password_text);
                local text_len = string.len(u8str);
                    if (text_len ~= 6) then
                        setting_dialog_view.game_streaming_password_len_limit_tips:Show(TRUE);
                    else 
                        setting_dialog_view.game_streaming_password_len_limit_tips:Show(FALSE);
                    end;
                else
                    setting_dialog_view.game_streaming_password_len_limit_tips:Show(FALSE);
                end;
            else
                setting_dialog_view.game_streaming_password_edit:Enable(FALSE);
                setting_dialog_view.game_streaming_password_len_limit_tips:Show(FALSE);
            end;

        end;
       
    end;
    
    signaled = function(uilib, dwClickId)
        if setting_dialog_view.is_flash_ui_complete == true then
            setting_dialog_view.inner_log("setting_dialog_view signaled id:"..dwClickId);
            -- 静默升级修改提示
            setting_dialog_view.check_unset_silent_update_show_tips();
            setting_dialog_view.check_all_setting();
        end;
        
        if nil ~= setting_dialog_view.game_streaming_enable_checkbox and 
        nil ~= setting_dialog_view.game_streaming_enable_warning_tips then
            setting_dialog_view.game_streaming_enable_warning_tips:Show(setting_dialog_view.game_streaming_enable_checkbox:IsChecked());
            setting_dialog_view.game_streaming_password_checkbox:Enable(setting_dialog_view.game_streaming_enable_checkbox:IsChecked());
            if setting_dialog_view.game_streaming_password_checkbox:IsChecked() == TRUE and 
                setting_dialog_view.game_streaming_enable_checkbox:IsChecked()  == TRUE then 
                setting_dialog_view.game_streaming_password_edit:Enable(TRUE);
                if setting_dialog_view.game_streaming_password_checkbox:IsChecked() == TRUE then
                local password_text = setting_dialog_view.game_streaming_password_edit:GetText();
                local u8str = CUIStrtoU8(password_text);
                local text_len = string.len(u8str);
                    if (text_len ~= 6) then
                        setting_dialog_view.game_streaming_password_len_limit_tips:Show(TRUE);
                    else 
                        setting_dialog_view.game_streaming_password_len_limit_tips:Show(FALSE);
                    end;
                else
                    setting_dialog_view.game_streaming_password_len_limit_tips:Show(FALSE);
                end;
            else
                setting_dialog_view.game_streaming_password_edit:Enable(FALSE);
                setting_dialog_view.game_streaming_password_len_limit_tips:Show(FALSE);
            end;
            
        end;
        
        if nil ~= setting_dialog_view.have_speed_limit_checkbox and 
        nil ~= setting_dialog_view.speed_input_edit and 
        nil ~= setting_dialog_view.no_speed_limit_checkbox then
            if dwClickId == setting_dialog_view.have_speed_limit_checkbox:GetControlID() then
                if setting_dialog_view.cfg_table["download_speed_limit"] == 0 then --之前没有速度限制
                    setting_dialog_view.speed_input_edit:Enable(TRUE);
                    local initSpeed = "4096";
                    local c_str = U8toCUIStr(initSpeed);
                    setting_dialog_view.speed_input_edit:SetFocus();
                    setting_dialog_view.speed_input_edit:SetText(c_str);
                end;            
                setting_dialog_view.speed_input_edit:Enable(TRUE);
            elseif dwClickId == setting_dialog_view.no_speed_limit_checkbox:GetControlID() then
                setting_dialog_view.speed_input_edit:Enable(FALSE);
            end;
        end
    end;
    
    onLanEnable = function(uilib, dwClickId)
        if nil ~=setting_dialog_view.game_linker_disable then
            setting_dialog_view.game_linker_disable:SetChecked(FALSE);
        end;
    end;
    
    onLanDisable = function(uilib, dwClickId)
        if nil ~=setting_dialog_view.game_linker_enable then
            setting_dialog_view.game_linker_enable:SetChecked(FALSE);
        end;
    end;
    
    onLanUnSignaled = function(uilib, dwClickId)
    end;

    check_all_setting = function()
        if setting_dialog_view.is_setting_change == false then
            local changed = setting_dialog_view.have_changed();
            if changed == true then
                setting_dialog_view.is_setting_change = true;
            end;
        end;
    end;
    
    have_changed = function()
        --
        local check_item = {
        "auto_start", "auto_login", "anchor_subscribe", "video_subscribe",
        "download_speed_limit", "close_main_wnd_oper", "start_game_tgp_wnd_oper",
        "auto_download_uncomplete_task", "after_install_pkgoper", "use_router_download_task",
        "after_buy_game_oper", "open_game_list_cloud_sync", "open_wegame_silent_update",
        "use_router_accelerate", "page_cache_setting", "page_preload_setting", 
        "game_screenshot_hotkey"
        };
        local new_cfg = setting_dialog_view.get_cfg_from_ui();
        local is_changed = false;
        for _, key in ipairs(check_item) do
            --setting_dialog_view.inner_log("key:"..key..", new value:"..new_cfg[key]..", old value:"..setting_dialog_view.cfg_table[key]);
            if new_cfg[key] ~= setting_dialog_view.cfg_table[key] then
                setting_dialog_view.inner_log("setting_dialog_view check cfg changed by user");
                is_changed = true;
                break;
            end;
        end;
        
        return is_changed;
    end;

    speed_changed = function(UILib,dwControlID)
        if nil ==  setting_dialog_view.speed_input_edit then
            return; 
        end

        local str = setting_dialog_view.speed_input_edit:GetText();
        local u8str = CUIStrtoU8(str);
        local dwSpeed = tonumber(u8str);
        if dwSpeed ~= nil then
            if dwSpeed == 0 then
                local const_str = U8toCUIStr("");
                setting_dialog_view.speed_input_edit:SetText(const_str);
            elseif dwSpeed > 10240 then
                local const_str = U8toCUIStr("10240");
                setting_dialog_view.speed_input_edit:SetText(const_str);
            end;
        end;
        setting_dialog_view.is_setting_change = true;
    end;
    
    ----------------------------------------------------
    set_setting_cfg = function(data)
        setting_dialog_view.inner_log("setting_dialog_view set_config");
        if data ~= nil then
            setting_dialog_view.cfg_table = data; -- base_utility.json_to_table(json_str);

            setting_dialog_view.anchor_subscribe_flag = setting_dialog_view.cfg_table["anchor_subscribe"];
            setting_dialog_view.video_subscribe_flag = setting_dialog_view.cfg_table["video_subscribe"];
            setting_dialog_view.cfg_table["dpi_setting"] = setting_dialog_control.get_dpi_setting();

            if setting_dialog_view.is_dev_client then
                local debug_setting = setting_dialog_control.get_debug_setting();
                if debug_setting ~= nil then
                    for k, v in pairs(debug_setting) do
                        setting_dialog_view.cfg_table[k] = v;
                    end;
                end
            end

            local mgr_info = comm_center.call_service("i_service_get_path_mgr_info", {});
            local info = base_utility.json_to_table(mgr_info.mgr_info);
            setting_dialog_view.cfg_table["setup_path"] = info.data;
        end
        
        setting_dialog_view.flash_ui();
    end;

    -- 获取磁盘可用磁盘空间返回
    get_free_space_resp = function(json_str)
        if nil == setting_dialog_view.tips_for_download_dir then
            return;
        end        

        local dwDownloadTipId = setting_dialog_view.tips_for_download_dir:GetControlID();
        local info_tab = base_utility.json_to_table(json_str);
        if info_tab and info_tab["ret"] == 1 then
            --查询成功            
            local space = info_tab["fmt_free_bytes_available"];
            local unit = base_utility.fix_disk_size_unit(
                info_tab["fmt_free_bytes_available_unit"]);
            base_utility.log(" space:"..space.."unit:"..unit);

            local str = LoadStr(ID_FREE_DISKSPACE);
            local normal_str = U8toCUIStr(str..space..unit);
            
            if dwDownloadTipId ==  setting_dialog_view.current_query_space_tip_id then
                setting_dialog_view.tips_for_download_dir:SetTextColor(
                setting_dialog_view.normal_color);
                setting_dialog_view.tips_for_download_dir:SetText(normal_str);
            end;
        else
            --查询失败
            local err_str = U8toCUIStr(LoadStr("DISK_SPACE_NOT_ENOUGH"));
            
            if dwDownloadTipId ==  setting_dialog_view.current_query_space_tip_id then
                setting_dialog_view.tips_for_download_dir:SetTextColor(
                setting_dialog_view.error_color);
                setting_dialog_view.tips_for_download_dir:SetText(err_str);
            end;
        end;

    end;
    
    flash_ui = function()
        setting_dialog_view.is_flash_ui_complete = false;
        setting_dialog_view.inner_log("setting_dialog_view flash ui begin...");
        --更新常规设置属性
        if nil ~= setting_dialog_view.auto_start_checkbox then
            if setting_dialog_view.cfg_table["auto_start"] == 1 then
                setting_dialog_view.auto_start_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.auto_start_checkbox:SetChecked(FALSE);
            end;
        end

        if nil ~= setting_dialog_view.auto_login_checkbox then
              if setting_dialog_view.is_netbar == 1 or (login_model.pwd_saved == false and setting_dialog_view.cfg_table["auto_login"] ~= 1) 
                then --网吧版本不需要自动登录, 没有保存密码也不能自动登录
                  setting_dialog_view.auto_login_checkbox:Enable(FALSE);
              else
                  if setting_dialog_view.cfg_table["auto_login"] == 1 then
                    setting_dialog_view.auto_login_checkbox:SetChecked(TRUE);
                else
                    setting_dialog_view.auto_login_checkbox:SetChecked(FALSE);
                end;
              end;
        end

        if nil ~= setting_dialog_view.anchor_subscribe_checkbox then
            if setting_dialog_view.cfg_table["anchor_subscribe"] == 1 then
                setting_dialog_view.anchor_subscribe_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.anchor_subscribe_checkbox:SetChecked(FALSE);
            end;
        end

        if nil ~= setting_dialog_view.video_subscribe_checkbox then
            if setting_dialog_view.cfg_table["video_subscribe"] == 1 then
                setting_dialog_view.video_subscribe_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.video_subscribe_checkbox:SetChecked(FALSE);
            end;
        end
        
        if nil ~= setting_dialog_view.mini_wnd_when_close_wnd_checkbox then
            if setting_dialog_view.cfg_table["close_main_wnd_oper"] == 0 then
                setting_dialog_view.mini_wnd_when_close_wnd_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.exit_wnd_when_close_wnd_checkbox:SetChecked(TRUE);
            end;
        end

        if nil ~= setting_dialog_view.mini_wnd_when_start_game_checkbox then
            if setting_dialog_view.cfg_table["start_game_tgp_wnd_oper"] == 1 then
                setting_dialog_view.mini_wnd_when_start_game_checkbox:SetChecked(TRUE);
            elseif setting_dialog_view.cfg_table["start_game_tgp_wnd_oper"] == 0 then
                setting_dialog_view.keep_wnd_when_start_game_checkbox:SetChecked(TRUE);
            end;
        end


        if setting_dialog_view.cfg_table["open_game_list_cloud_sync"] == 1 then
            setting_dialog_view.open_game_list_cloud_sync_checkbox:SetChecked(TRUE);
        else
            setting_dialog_view.open_game_list_cloud_sync_checkbox:SetChecked(FALSE);
        end;

         
        --[[if setting_dialog_view.cfg_table["game_streaming_server_enable"] == 1 then            
            if setting_dialog_view.cfg_table["game_streaming_enable"] == 1 then
                setting_dialog_view.game_streaming_enable_checkbox:SetChecked(TRUE);
                setting_dialog_view.game_streaming_enable_warning_tips:Show(TRUE);
            else
                setting_dialog_view.game_streaming_enable_checkbox:SetChecked(FALSE);
                setting_dialog_view.game_streaming_enable_warning_tips:Show(FALSE);
            end;

            if setting_dialog_view.cfg_table["game_streaming_enable_password"] == 1 then
                setting_dialog_view.game_streaming_password_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.game_streaming_password_checkbox:SetChecked(FALSE);
            end;
            
            if nil ~= setting_dialog_view.cfg_table["game_streaming_password"] and nil ~= setting_dialog_view.game_streaming_password_edit then
                local game_streaming_password = U8toCUIStr(setting_dialog_view.cfg_table["game_streaming_password"]);
                setting_dialog_view.game_streaming_password_edit:SetText(game_streaming_password);
            end;
        else 
            setting_dialog_view.game_streaming_tab_container:Show(FALSE);
            setting_dialog_view.game_streaming_tab_button:Show(FALSE);
        end;
        ]]--
        setting_dialog_view.inner_log("setting_dialog_view game_linker_enable_qrcode %d", setting_dialog_view.cfg_table["game_linker_enable_qrcode"]);
        
        if nil ~= setting_dialog_view.game_linker_qrcode and 
           setting_dialog_view.cfg_table["game_linker_enable_qrcode"] == 1 then
           setting_dialog_view.inner_log("setting_dialog_view game_linker_enable_qrcode set qrcode" );
            local sImage = "game_linker\\game_linker_qrcode.png";
            sImage = base_utility.get_work_path() .. "\\tpf_ui\\res\\dl\\" .. sImage;

            local sTemp = "ONEIMAGE:".. sImage ..";Stretch;0;";

            ui_utility.setproperty_by_id(setting_dialog_view.game_linker_qrcode:GetControlID(), 
                                         "Background", sTemp);
        end;
        
        if nil ~= setting_dialog_view.game_linker_ip_text then
           local sTemp = setting_dialog_view.cfg_table["game_linker_ipinfo"];
           setting_dialog_view.inner_log("setting_dialog_view game_linker_ip_text ".. sTemp );
           ui_utility.setproperty_by_id(setting_dialog_view.game_linker_ip_text:GetControlID(), 
                                         "Caption", sTemp);
        end;
        
        if nil ~= setting_dialog_view.game_linker_account_name then
           local get_account_name_service = {};
           local ret_value = comm_center.call_service("i_servie_get_self_game_info",
           get_account_name_service);
           if ret_value ~= nil then
               local sTemp = ret_value.nick_name;
               if sTemp == nil then
                   sTemp = "";
               end;
               local lan_gamelinker_text = LoadStr("LAN_GAME_LINKER_TEXT");
           
                local str = "";
                str = string.format(lan_gamelinker_text, sTemp);
                setting_dialog_view.inner_log("setting_dialog_view game_linker_account_name ".. sTemp );
                ui_utility.setproperty_by_id(setting_dialog_view.game_linker_account_name:GetControlID(), 
                                                 "Caption", str);
            end;
        end;
        
        if nil ~= setting_dialog_view.game_linker_pc_name then
           local get_computer_name_service = {};
           local ret_value = comm_center.call_service("Svr_GameInStreamingGetComputerName",
           get_computer_name_service);
           if ret_value ~= nil then
               local sTemp = ret_value.computer_name;
               if sTemp == nil then
                   sTemp = "";
               end;
               local lan_gamelinker_authorize_text = LoadStr("LAN_GAME_LINKER_AUTHORIZE_TEXT");
               local str = "";
               str = string.format(lan_gamelinker_authorize_text, sTemp);
               setting_dialog_view.inner_log("setting_dialog_view game_linker_pc_name ".. sTemp );
               ui_utility.setproperty_by_id(setting_dialog_view.game_linker_pc_name:GetControlID(), 
                                         "Caption", str);
            end;                             
        end;
        
        
        if nil ~= setting_dialog_view.game_linker_enable and nil ~= setting_dialog_view.game_linker_disable then
           local is_enable = setting_dialog_view.cfg_table["game_streaming_enable"];
           if is_enable == nil then
               is_enable = 0;
           end;
           setting_dialog_view.game_linker_enable:SetChecked(FALSE);
           setting_dialog_view.game_linker_disable:SetChecked(FALSE);
           if is_enable == 1 then
             setting_dialog_view.game_linker_enable:SetChecked(TRUE);
           end;
           
            if is_enable == 0 then
             setting_dialog_view.game_linker_disable:SetChecked(TRUE);
           end;
        end;
        
        if setting_dialog_view.is_netbar == 1 and nil ~=setting_dialog_view.game_linker_account_name 
            and nil ~= setting_dialog_view.game_linker_pc_name_tip and nil ~= setting_dialog_view.game_linker_enable and nil ~= setting_dialog_view.game_linker_disable then 
            setting_dialog_view.game_linker_account_name:Show(FALSE);
            setting_dialog_view.game_linker_enable:Show(FALSE);
            setting_dialog_view.game_linker_disable:Show(FALSE);
            setting_dialog_view.game_linker_pc_name_tip:Show(FALSE);
        end;
        -- 非网吧版本才有静默升级
        if setting_dialog_view.is_netbar ~= 1 then 
            if setting_dialog_view.cfg_table["open_wegame_silent_update"] == 1 then
                setting_dialog_view.open_wegame_silent_update_checkbox:SetChecked(TRUE);
                setting_dialog_view.open_wegame_silent_update_warning_tips:Show(FALSE);
                setting_dialog_view.open_wegame_silent_update_warning_tips_show = false;
            else
                setting_dialog_view.open_wegame_silent_update_checkbox:SetChecked(FALSE);
                setting_dialog_view.open_wegame_silent_update_warning_tips:Show(TRUE);
                setting_dialog_view.open_wegame_silent_update_warning_tips_show = true;
            end;
        else
            setting_dialog_view.open_wegame_silent_update_checkbox:Enable(FALSE);
            setting_dialog_view.open_wegame_silent_update_checkbox:SetChecked(FALSE);
            setting_dialog_view.open_wegame_silent_update_warning_tips:Show(FALSE);
            setting_dialog_view.open_wegame_silent_update_warning_tips_show = false;
        end
        
        --应用内截图
        if setting_dialog_view.app_inner_screenshot_combobox ~= nil then
            local str_hotkey_1, strHolder = U8toCUIStr(LoadStr("APP_INNER_SCREENSHOT_HOTKEY_1"));
            local str_hotkey_2, strHolder = U8toCUIStr(LoadStr("APP_INNER_SCREENSHOT_HOTKEY_2"));
            local str_hotkey_3, strHolder = U8toCUIStr(LoadStr("APP_INNER_SCREENSHOT_HOTKEY_3"));
            local str_hotkey_4, strHolder = U8toCUIStr(LoadStr("APP_INNER_SCREENSHOT_HOTKEY_4"));
            setting_dialog_view.app_inner_screenshot_combobox:AppendItem(str_hotkey_1);
            setting_dialog_view.app_inner_screenshot_combobox:AppendItem(str_hotkey_2);
            setting_dialog_view.app_inner_screenshot_combobox:AppendItem(str_hotkey_3);
            setting_dialog_view.app_inner_screenshot_combobox:AppendItem(str_hotkey_4);
            local hot_key_str_list = {str_hotkey_1, str_hotkey_2, str_hotkey_3, str_hotkey_4};
            local key_cfg_str = setting_dialog_view.cfg_table["game_screenshot_hotkey"];
            if key_cfg_str ~= nil and cfg_key ~= "" then
                for k,v in pairs(setting_dialog_view.screenshot_cfg_vlaue_list) do
                    if v == key_cfg_str then
                        setting_dialog_view.app_inner_screenshot_combobox:SetSelString(
                            hot_key_str_list[k]);
                    end
                end
            else
                setting_dialog_view.app_inner_screenshot_combobox:SetSelString(str_hotkey_1);
            end
        end

        -- 页面缓存设置开关
        if setting_dialog_view.open_page_cache_setting_checkbox ~= nil then
            if setting_dialog_view.cfg_table["page_cache_setting"] == 1 then
                setting_dialog_view.open_page_cache_setting_checkbox:SetChecked(TRUE);
            else 
                setting_dialog_view.open_page_cache_setting_checkbox:SetChecked(FALSE);
            end
        end

        -- 页面预加载设置开关
        if setting_dialog_view.open_page_preload_checkbox ~= nil then
            if setting_dialog_view.cfg_table["page_preload_setting"] == 1 then
                 setting_dialog_view.open_page_preload_checkbox:SetChecked(TRUE);
            else 
                 setting_dialog_view.open_page_preload_checkbox:SetChecked(FALSE);
            end
        end

        ------游戏下载设置
        if nil ~= setting_dialog_view.cfg_table["download_path"] and nil ~= setting_dialog_view.download_path_edit then
            local const_ui_str = U8toCUIStr(setting_dialog_view.cfg_table["download_path"]);
            setting_dialog_view.download_path_edit:SetText(const_ui_str);
        end
        
        if nil ~= setting_dialog_view.tips_for_download_dir then
            --获取磁盘空间大小
            if setting_dialog_view.tab_page == 1 and setting_dialog_view.open_reason == 1 then
                --显示磁盘空间不足
                local err_str, str_holder = U8toCUIStr(LoadStr("DISK_SPACE_NOT_ENOUGH"));
                setting_dialog_view.tips_for_download_dir:SetTextColor(setting_dialog_view.error_color);
                setting_dialog_view.tips_for_download_dir:SetText(err_str);
            else
                --先设置，再查询
                setting_dialog_view.current_query_space_tip_id = setting_dialog_view.tips_for_download_dir:GetControlID();            
                local const_download_path_str = NewStr(500);
                const_download_path_str = setting_dialog_view.cfg_table["download_path"];
                setting_dialog_control.get_free_space(const_download_path_str, 500);
            end;
        end
        
        --安装路径管理
        if nil ~= setting_dialog_view.cfg_table["setup_path"] and 
            nil ~= setting_dialog_view.install_path_mgr_cnt then
            local path_data = setting_dialog_view.cfg_table["setup_path"];
            setting_dialog_view.update_install_path_setting_ui(path_data);
        end

        if nil ~= setting_dialog_view.tips_for_install_dir  then
            --获取磁盘空间大小
            if setting_dialog_view.tab_page == 1 and setting_dialog_view.open_reason == 1 then
                --显示磁盘空间不足
                local err_str, str_holder = U8toCUIStr(LoadStr("DISK_SPACE_NOT_ENOUGH"));
                setting_dialog_view.tips_for_install_dir:SetTextColor(setting_dialog_view.error_color);
                setting_dialog_view.tips_for_install_dir:SetText(err_str);
            else            
                setting_dialog_view.current_query_space_tip_id = setting_dialog_view.tips_for_install_dir:GetControlID();    
                local const_install_path_str = NewStr(500);
                const_install_path_str = setting_dialog_view.cfg_table["setup_path"];
                setting_dialog_control.get_free_space(const_install_path_str, 500);
            end;
        end

        if nil ~= setting_dialog_view.auto_download_checkbox then
            if setting_dialog_view.cfg_table["auto_download_uncomplete_task"] == 1 then
                setting_dialog_view.auto_download_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.auto_download_checkbox:SetChecked(FALSE);
            end;
        end

        if nil ~= setting_dialog_view.router_download_checkbox then
            if setting_dialog_view.cfg_table["use_router_download_task"] == 1 then
                setting_dialog_view.router_download_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.router_download_checkbox:SetChecked(FALSE);
            end;
        end

        if nil ~= setting_dialog_view.router_download_checkbox then
            -- 根据路由器传来的字段值再重新设置勾选状态
            if setting_dialog_model.is_predownload_status == true then
                setting_dialog_view.router_download_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.router_download_checkbox:SetChecked(FALSE);
            end;
        end

        if nil ~= setting_dialog_view.router_download_checkbox then
            -- 根据路由器传来的字段值再重新设置加速勾选状态
            if setting_dialog_model.accl_status == true then
                setting_dialog_view.router_accelerate_setting_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.router_accelerate_setting_checkbox:SetChecked(FALSE);
            end;
        end

        if nil ~= setting_dialog_view.have_speed_limit_checkbox  then
            if setting_dialog_view.cfg_table["download_speed_limit"] == 0 then
                setting_dialog_view.no_speed_limit_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.have_speed_limit_checkbox:SetChecked(TRUE);
                local dwSpeed = setting_dialog_view.cfg_table["download_speed"];
                local u8_str = tostring(dwSpeed);
                local const_str, str_holder = U8toCUIStr(u8_str);
                setting_dialog_view.speed_input_edit:SetText(const_str);
            end;
        end

        if nil ~= setting_dialog_view.save_delete_checkbox then
            if setting_dialog_view.cfg_table["after_install_pkgoper"] == 0 then
                setting_dialog_view.save_delete_checkbox:SetChecked(TRUE);
            elseif setting_dialog_view.cfg_table["after_install_pkgoper"] == 1 then
                setting_dialog_view.save_7days_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.save_forever_checkbox:SetChecked(TRUE);
            end;
        end

        if nil ~= setting_dialog_view.after_buy_game_oper_checkbox then
            if setting_dialog_view.cfg_table["after_buy_game_oper"] == 0 then
                setting_dialog_view.after_buy_game_oper_checkbox:SetChecked(FALSE);
            else
                setting_dialog_view.after_buy_game_oper_checkbox:SetChecked(TRUE);
            end
        end

        if setting_dialog_view.anti_addiction_checkbox ~= nil  then
            if setting_dialog_view.cfg_table["skip_anti_addition_check"] == 1 then
                setting_dialog_view.anti_addiction_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.anti_addiction_checkbox:SetChecked(FALSE);
            end
        end;

        if setting_dialog_view.detail_log_checkbox ~= nil then
            if setting_dialog_view.cfg_table["detail_log"] == 1 then
                setting_dialog_view.detail_log_checkbox:SetChecked(TRUE);
            else
                setting_dialog_view.detail_log_checkbox:SetChecked(FALSE);
            end
        end;

        setting_dialog_view.refresh_subscribe_after_open_dl_ui();

        if setting_dialog_view.cfg_table["dpi_setting"] == 1 then
            setting_dialog_view.dpi_setting_checkbox:SetChecked(TRUE);
        else
            setting_dialog_view.dpi_setting_checkbox:SetChecked(FALSE);
        end;

        setting_dialog_view.is_flash_ui_complete = true;
        setting_dialog_view.inner_log("setting_dialog_view flash ui end.....");

    end;
    
    --获取路径是异步的，这里响应
    get_path_rsp = function(json_str)
        local param_table = base_utility.json_to_table(json_str);
          local path = "";
          if param_table and param_table["result"] == 1 then
              path = param_table["path"];
          end

        if string.len(path) > 0 then
            local app_dir = "WeGameApps";
            if base_utility.CLIENT_TYPE.OVERSEA_VER == base_utility.get_client_version_type() then
                app_dir = "WeGameXApps";
            end
            if base_utility.string_end_with(path, "\\") then
                path = path .. app_dir;
            else
                if false == base_utility.string_end_with(path, app_dir) then
                    path = path .. "\\" .. app_dir;
                end
            end
            local c_ui_str = U8toCUIStr(path);
            if setting_dialog_view.current_query_space_tip_id == setting_dialog_view.tips_for_download_dir:GetControlID() then
                setting_dialog_view.download_path_edit:SetText(c_ui_str);
            else
                setting_dialog_view.install_path_edit:SetText(c_ui_str);
            end
            setting_dialog_view.is_setting_change = true;
            
            --获取大小
            local const_download_path_str = NewStr(500);
            const_download_path_str = path;
            setting_dialog_control.get_free_space(const_download_path_str, 500);            
        end
    end;

    --下载路径执行
    set_download_path = function(uilib, dwClickId)
        if nil == setting_dialog_view.tips_for_download_dir or nil == setting_dialog_view.dialog_ptr then
            return;
        end
        setting_dialog_view.current_query_space_tip_id = setting_dialog_view.tips_for_download_dir:GetControlID();            
        local wnd = setting_dialog_view.dialog_ptr:GetHwnd();
        setting_dialog_control.get_path(wnd, setting_dialog_view.cfg_table["download_path"]);
    end;
    
    --安装路径选择按钮执行
    set_install_path = function(uilib, dwClickId)
        if nil == setting_dialog_view.install_path_mgr_cnt or nil == setting_dialog_view.dialog_ptr then
            return;
        end
        -- open install_path_mgr
         local req_data = {};
         comm_center.call_service("i_svr_show_install_path_mgr", req_data);
        base_utility.mainframe_report("main_window", "install_path_btn_click", "install_path_mgr");
    end;
    
    ----------------------------------------
    create_dialog = function()
        local layout_file = "WeGameSysSettingDlg.tpf";
        if base_utility.CLIENT_TYPE.OVERSEA_VER == base_utility.get_client_version_type() then
            layout_file = "WeGameSysSettingDlgOS.tpf";
        end
        setting_dialog_view.dialog_id = layout_mgr.restore_layout(layout_file,
            AutoCloseOpt.kAutoClose);
        if setting_dialog_view.dialog_id ~= 0 then
            if setting_dialog_view.is_dev_client then
                ui_utility.setproperty_by_path(setting_dialog_view.dialog_id, 
                    "tab_ctn\\ButtonGroup\\BtnDeveloperTool", "Visible", "true");
            end
            setting_dialog_view.dialog_ptr = ui_utility.get_ctrl_ptr_by_id(setting_dialog_view.dialog_id);        
            if nil ~= setting_dialog_view.dialog_ptr then
                setting_dialog_view.dialog_ptr:Show(FALSE);
            end
            -- 创建阴影
            --shadow_helper.create_shadow(setting_dialog_view.dialog_id);
        else
            setting_dialog_view.inner_log("create setting_dialog_view dialog error!");
        end;
    end;
    
    get_ui_control = function()
        setting_dialog_view.get_normal_setting_control();
        setting_dialog_view.get_game_download_setting_control();
        setting_dialog_view.get_debug_setting_control();
    end;
    
    --@brief return a table
    get_cfg_from_ui = function()
        local current_cfg = {};
        --常规设置
        current_cfg['auto_start'] = 0;
        if nil ~= setting_dialog_view.auto_start_checkbox and 
            setting_dialog_view.auto_start_checkbox:IsChecked() == TRUE then
            current_cfg['auto_start'] = 1;
        end;
        
        current_cfg['auto_login'] = 0;
        if nil ~= setting_dialog_view.auto_login_checkbox and 
            setting_dialog_view.auto_login_checkbox:IsChecked() == TRUE then
            current_cfg['auto_login'] = 1;
        end;

        current_cfg['anchor_subscribe'] = 0;
        if nil ~= setting_dialog_view.anchor_subscribe_checkbox and 
            setting_dialog_view.anchor_subscribe_checkbox:IsChecked() == TRUE then
            current_cfg['anchor_subscribe'] = 1;
        end;
        
        current_cfg['video_subscribe'] = 0;
        if nil ~= setting_dialog_view.video_subscribe_checkbox and 
            setting_dialog_view.video_subscribe_checkbox:IsChecked() == TRUE then
            current_cfg['video_subscribe'] = 1;
        end;
            
        current_cfg['close_main_wnd_oper'] = 0; --关闭面板时的动作 0-最小化,1-退出 
        if nil ~= setting_dialog_view.exit_wnd_when_close_wnd_checkbox and
            setting_dialog_view.exit_wnd_when_close_wnd_checkbox:IsChecked() == TRUE then
            current_cfg['close_main_wnd_oper'] = 1;
        end;
        
        current_cfg['start_game_tgp_wnd_oper'] = 0; --启动游戏后的动作 0--保持界面，1--最小化, 2--保持mini模式
        if nil ~= setting_dialog_view.mini_wnd_when_start_game_checkbox and 
            setting_dialog_view.mini_wnd_when_start_game_checkbox:IsChecked() == TRUE then
            current_cfg['start_game_tgp_wnd_oper'] = 1;
        end;

        current_cfg["after_buy_game_oper"] = 0;
        if nil ~= setting_dialog_view.after_buy_game_oper_checkbox and 
            setting_dialog_view.after_buy_game_oper_checkbox:IsChecked() == TRUE then
            current_cfg["after_buy_game_oper"] = 1;
        end

        current_cfg["open_game_list_cloud_sync"] = 0;
        if nil ~= setting_dialog_view.open_game_list_cloud_sync_checkbox and 
            setting_dialog_view.open_game_list_cloud_sync_checkbox:IsChecked() == TRUE then
            current_cfg["open_game_list_cloud_sync"] = 1;
        end;

        current_cfg["game_screenshot_hotkey"] = setting_dialog_view.screenshot_cfg_vlaue_list[1];
        if nil ~= setting_dialog_view.app_inner_screenshot_combobox then
            local cur_select = setting_dialog_view.app_inner_screenshot_combobox:GetCurSel();
            if cur_select ~= nil and type(cur_select) == "number" then
                current_cfg["game_screenshot_hotkey"] = 
                    setting_dialog_view.screenshot_cfg_vlaue_list[cur_select+1];
            end
        end;

        current_cfg["game_streaming_enable"] = 0;
        if nil ~= setting_dialog_view.game_linker_enable and 
            setting_dialog_view.game_linker_enable:IsChecked() == TRUE then
            current_cfg["game_streaming_enable"] = 1;
        end;
        
        current_cfg["game_streaming_enable_password"] = 0;
        if nil ~= setting_dialog_view.game_streaming_password_checkbox and 
            setting_dialog_view.game_streaming_password_checkbox:IsChecked() == TRUE then
            current_cfg["game_streaming_enable_password"] = 1;
        end;
        
        current_cfg["game_streaming_password"] = "";
        if nil ~=  setting_dialog_view.game_streaming_password_edit then
            local cui_path = setting_dialog_view.game_streaming_password_edit:GetText();
            local u8_path = CUIStrtoU8(cui_path);
            current_cfg['game_streaming_password'] = u8_path;
        end;

        
        -- 静默升级相关选项
        if setting_dialog_view.is_netbar ~= 1 then 
            current_cfg["open_wegame_silent_update"] = 0;
            if nil ~= setting_dialog_view.open_wegame_silent_update_checkbox and 
                setting_dialog_view.open_wegame_silent_update_checkbox:IsChecked() == TRUE then
                current_cfg["open_wegame_silent_update"] = 1;
            end;        
        else
            current_cfg["open_wegame_silent_update"] = setting_dialog_view.cfg_table["open_wegame_silent_update"];
        end;

        -- 页面缓存设置
        current_cfg["page_cache_setting"] = 0;
        if setting_dialog_view.open_page_cache_setting_checkbox ~= nil and
            setting_dialog_view.open_page_cache_setting_checkbox:IsChecked() == TRUE then
            current_cfg["page_cache_setting"] = 1;
        end;

        -- 页面预加载设置
        current_cfg["page_preload_setting"] = 0;
        if setting_dialog_view.open_page_preload_checkbox ~= nil and
            setting_dialog_view.open_page_preload_checkbox:IsChecked() == TRUE then
            current_cfg["page_preload_setting"] = 1;
        end;
        
        --游戏下载设置
        current_cfg['download_path'] = ""; --下载路径
        if nil ~=  setting_dialog_view.download_path_edit then
            local cui_path = setting_dialog_view.download_path_edit:GetText();
            local u8_path = CUIStrtoU8(cui_path);
            current_cfg['download_path'] = u8_path;
            --setting_dialog_view.inner_log("u8_path:"..u8_path..",save str:"..current_cfg['download_path']);
        end

        current_cfg['auto_download_uncomplete_task'] = 0;     --1 - 是， 0 - 否
        if nil ~= setting_dialog_view.auto_download_checkbox and 
            setting_dialog_view.auto_download_checkbox:IsChecked() == TRUE then
            current_cfg['auto_download_uncomplete_task'] = 1;
        end;

        current_cfg['use_router_download_task'] = 0;    --1 -是, 0 - 否
        if nil ~= setting_dialog_view.router_download_checkbox and 
            setting_dialog_view.router_download_checkbox:IsChecked() == TRUE then
            current_cfg['use_router_download_task'] = 1;
            setting_dialog_model.is_predownload_status = true;
        else
            setting_dialog_model.is_predownload_status = false;
        end;

        current_cfg['use_router_accelerate'] = 0;    --1 -是, 0 - 否
        if nil ~= setting_dialog_view.router_accelerate_setting_checkbox and 
            setting_dialog_view.router_accelerate_setting_checkbox:IsChecked() == TRUE then
            current_cfg['use_router_accelerate'] = 1;
            setting_dialog_model.accl_status = true;
        else
            setting_dialog_model.accl_status = false;
        end;
        
        current_cfg['download_speed_limit'] = 0; --1 - 是， 0 - 否  
        local dwspeed_default = 4096;  -- 如果限速值设置为空，则默认重置为4096.
        current_cfg['download_speed'] = dwspeed_default;        
        if nil ~= setting_dialog_view.have_speed_limit_checkbox and 
            nil ~= setting_dialog_view.speed_input_edit and 
            setting_dialog_view.have_speed_limit_checkbox:IsChecked() == TRUE then
            current_cfg['download_speed_limit'] = 1;
            local const_str = setting_dialog_view.speed_input_edit:GetText();
            local u8_str = CUIStrtoU8(const_str);
            local dwSpeed = tonumber(u8_str);
            if dwSpeed ~= nil then
                current_cfg['download_speed'] = dwSpeed;
            else
                local c_str, str_holder = U8toCUIStr(dwspeed_default);
                setting_dialog_view.speed_input_edit:SetFocus();
                setting_dialog_view.speed_input_edit:SetText(c_str);
            end;
        end;
        
        current_cfg['after_install_pkgoper'] = 0;            --0-删除,1-保留7天,2-永久保留
        if nil ~= setting_dialog_view.save_delete_checkbox and 
            nil ~= setting_dialog_view.save_7days_checkbox and 
            nil ~= setting_dialog_view.save_forever_checkbox then
            if setting_dialog_view.save_delete_checkbox:IsChecked() == TRUE then
                current_cfg['after_install_pkgoper'] = 0;
            elseif setting_dialog_view.save_7days_checkbox:IsChecked() == TRUE then
                current_cfg['after_install_pkgoper'] = 1;
            elseif setting_dialog_view.save_forever_checkbox:IsChecked() == TRUE then
                current_cfg['after_install_pkgoper'] = 2;
            end;        
        end

        current_cfg["after_buy_game_oper"] = 0;
        if nil ~= setting_dialog_view.after_buy_game_oper_checkbox and  
           setting_dialog_view.after_buy_game_oper_checkbox:IsChecked() == TRUE then
            current_cfg["after_buy_game_oper"] = 1;
        end
        
        current_cfg["subscribe_after_open_download"] = 0;
        if nil ~= setting_dialog_view.subscribe_after_open_download_checkbox and
            setting_dialog_view.subscribe_after_open_download_checkbox:IsChecked() == TRUE then
            current_cfg["subscribe_after_open_download"] = 1;
        end

        current_cfg["dpi_setting"] = 0;
        if nil ~= setting_dialog_view.dpi_setting_checkbox and 
            setting_dialog_view.dpi_setting_checkbox:IsChecked() == TRUE then
            current_cfg["dpi_setting"] = 1;
        end

        if setting_dialog_view.is_dev_client then
            current_cfg["skip_anti_addition_check"] = 1;
            if setting_dialog_view.anti_addiction_checkbox ~= nil and
                setting_dialog_view.anti_addiction_checkbox:IsChecked() == FALSE then
                current_cfg["skip_anti_addition_check"] = 0;
            end;

            current_cfg["detail_log"] = 0;
            if setting_dialog_view.detail_log_checkbox ~= nil and
                setting_dialog_view.detail_log_checkbox:IsChecked() == TRUE then
                current_cfg["detail_log"] = 1;
            end;
        end;

        return current_cfg;
    end;

    
    ---切换标签
    switch_tabl = function(json_str)    
        if nil == setting_dialog_view.tab_exclude_ctrl then
            return; 
        end

        setting_dialog_view.open_reason = 0;
        setting_dialog_view.tab_page = 0;
        if json_str ~= nil then
            local param_tab = base_utility.json_to_table(json_str);
            if param_tab then
                -- setting_dialog_view.anchor_subscribe_flag = param_tab["anchor_subscribe"];
                -- setting_dialog_view.video_subscribe_flag = param_tab["video_subscribe"];
                setting_dialog_view.open_reason = param_tab["reason"];
                setting_dialog_view.tab_page = param_tab["tab_page"]; 
            else
                setting_dialog_view.inner_log("setting_dialog_view get tab from json str error!");
            end;
        end;
        
        if setting_dialog_view.tab_page == 0 then
            setting_dialog_view.tab_exclude_ctrl:SetCheckedIndex(0);
        elseif setting_dialog_view.tab_page == 1 then
            setting_dialog_view.tab_exclude_ctrl:SetCheckedIndex(1);
        elseif setting_dialog_view.tab_page == 2 then
            setting_dialog_view.tab_exclude_ctrl:SetCheckedIndex(1);
        else 
            setting_dialog_view.inner_log("setting_dialog_view switch tabl param error!");
        end;
    end;
    
    --获取控件指针
    get_normal_setting_control = function()
        if nil ~= setting_dialog_view.dialog_ptr then
            --获取常规设置控件
            
            setting_dialog_view.tab_exclude_ctrl = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\ButtonGroup\\Excluder_ForTabSwitch");
            
            --获取游戏下载设置控件
            --游戏下载设置控件
            setting_dialog_view.auto_start_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_AutoStart");
            
            setting_dialog_view.auto_login_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_AutoLogin");
            
            setting_dialog_view.anchor_subscribe_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_AnchorSubscribe");

            setting_dialog_view.video_subscribe_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_VideoSubscribe");
            
            setting_dialog_view.mini_wnd_when_close_wnd_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_MiniWhenClose");
            
            setting_dialog_view.exit_wnd_when_close_wnd_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_ExitWhenClose");
            
            setting_dialog_view.mini_wnd_when_start_game_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbt_MiniWhenGame");
            
            setting_dialog_view.keep_wnd_when_start_game_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbt_KeepWhenGame");
            
            setting_dialog_view.switch_to_mini_mode_when_start_game_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbt_SwitchMiniModeWhenGame");

            setting_dialog_view.open_game_list_cloud_sync_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_CloudSyncSetting");

            setting_dialog_view.open_wegame_silent_update_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_SilentUpdate");

            setting_dialog_view.open_wegame_silent_update_warning_tips = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\SilentUpdateWarningTips");

            setting_dialog_view.app_inner_screenshot_combobox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, 
                "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_AppScreenshot");

            setting_dialog_view.open_page_cache_setting_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_PageCacheSetting");

            setting_dialog_view.open_page_preload_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_PagePreLoadSetting");

            setting_dialog_view.router_accelerate_setting_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_RouterSetting");

            setting_dialog_view.select_lanuage_combox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_SelectLanguage");

            setting_dialog_view.select_lanuage_txt = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\LanguageSettingTxt");

            setting_dialog_view.dpi_setting_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_DPISetting");
                            
            setting_dialog_view.game_streaming_tab_container =  ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameStreamingTab");
                
            setting_dialog_view.game_streaming_tab_button =  ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\ButtonGroup\\BtnGameStreaming");
            
            setting_dialog_view.game_streaming_enable_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameStreamingTab\\Cbx_LanGameStreamingEnable");
                
            setting_dialog_view.game_streaming_enable_warning_tips = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameStreamingTab\\LanGameStreamingWarningTxt");
            
            setting_dialog_view.game_streaming_password_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameStreamingTab\\Cbx_LanGameStreamingPwdSetting");
            
            setting_dialog_view.game_streaming_password_edit = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameStreamingTab\\Cbx_LanGameStreamingPasswordEdit");
                
            setting_dialog_view.game_streaming_password_len_limit_tips = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameStreamingTab\\Cbx_LanGameStreamingPwdSettingText");
         
            setting_dialog_view.game_linker_qrcode = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameLinkerTab\\GameLinerQRPic");
                
            setting_dialog_view.game_linker_ip_text = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameLinkerTab\\GameLinkerIP\\LanGameLinkerIP2");   
                
            setting_dialog_view.game_linker_account_name = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameLinkerTab\\LanGameLinkerText\\LanGameLinkerTxt");

            setting_dialog_view.game_linker_pc_name = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameLinkerTab\\LanGameLinkerAuthorizeTxt");

            setting_dialog_view.game_linker_enable = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameLinkerTab\\LanGameLinkerEnable");

            setting_dialog_view.game_linker_disable = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameLinkerTab\\LanGameLinkerDisable");

             setting_dialog_view.game_linker_pc_name_tip = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\GameLinkerTab\\LanGameLinkerAuthorizeTipTxt");

            -- 路由逻辑--
            local normal_line6_ptr = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\SeperateLine6");
            local router_accelerate_setting_title_ptr = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\RouterSettingTxt");
            local router_accelerate_setting_checkbox_id = ui_utility.get_ctrl_id_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal\\Cbx_RouterSetting");

            if setting_dialog_model.vendor == "xiaomi" then
                normal_line6_ptr:Show(TRUE);
                router_accelerate_setting_title_ptr:Show(TRUE);
                ui_utility.setproperty_by_id(router_accelerate_setting_checkbox_id, "Caption", LoadStr("ROUTER_SETTING_XIAOMI"));
                setting_dialog_view.router_accelerate_setting_checkbox:Show(TRUE);
            elseif setting_dialog_model.vendor == "huawei" then
                normal_line6_ptr:Show(TRUE);
                router_accelerate_setting_title_ptr:Show(TRUE);
                ui_utility.setproperty_by_id(router_accelerate_setting_checkbox_id, "Caption", LoadStr("ROUTER_SETTING_HUAWEI"));
                setting_dialog_view.router_accelerate_setting_checkbox:Show(TRUE);
            else
                normal_line6_ptr:Show(FALSE);
                router_accelerate_setting_title_ptr:Show(FALSE);
                setting_dialog_view.router_accelerate_setting_checkbox:Show(FALSE);
            end;

            -- 如果是国际版本，初始化
             if base_utility.CLIENT_TYPE.OVERSEA_VER ==  base_utility.get_client_version_type() == true or 
                     setting_dialog_view.is_dev_client == true then
                setting_dialog_view.select_lanuage_combox:Show(TRUE);
                setting_dialog_view.select_lanuage_txt:Show(TRUE);
                normal_line6_ptr:Show(TRUE);
                setting_dialog_view.init_change_lanuage_setting();
             else
                setting_dialog_view.select_lanuage_combox:Show(FALSE);
                   setting_dialog_view.select_lanuage_txt:Show(FALSE);
             end
        end;
    end;

    get_debug_setting_control = function()
        if setting_dialog_view.is_dev_client == false then
            return;
        end

        if setting_dialog_view.dialog_ptr ~= nil then
            setting_dialog_view.anti_addiction_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, 
                "tab_ctn\\OverlapCtnTab\\ScrollViewDeveloperTab\\Ctn_Developer\\Cbx_AntiAddiction");
            setting_dialog_view.detail_log_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id,
                "tab_ctn\\OverlapCtnTab\\ScrollViewDeveloperTab\\Ctn_Developer\\Cbx_DetialLog");
            setting_dialog_view.select_game_duration_combox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id,
                "tab_ctn\\OverlapCtnTab\\ScrollViewDeveloperTab\\Ctn_Developer\\Cbx_AntiAddictionTimeType");
            setting_dialog_view.game_id_combox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id,
                "tab_ctn\\OverlapCtnTab\\ScrollViewDeveloperTab\\Ctn_Developer\\Cbx_AntiAddictionAppID");
            setting_dialog_view.game_duration_tips = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id,
                "tab_ctn\\OverlapCtnTab\\ScrollViewDeveloperTab\\Ctn_Developer\\OperateDurationTips");
            
            local str, strholder = U8toCUIStr(LoadStr("ID_TPF_GAME_DURATION_TYPE_OPTION1"));
            if setting_dialog_view.select_game_duration_combox ~= nil then
                setting_dialog_view.select_game_duration_combox:AppendItem(str);
                str, strholder = U8toCUIStr(LoadStr("ID_TPF_GAME_DURATION_TYPE_OPTION2"));
                setting_dialog_view.select_game_duration_combox:AppendItem(str);
                setting_dialog_view.select_game_duration_combox:SetCurSel(0);
            end

            if setting_dialog_view.game_id_combox ~= nil then
                if setting_dialog_view.developer_game_list == nil then
                    local data = comm_center.call_service("Svr_GetDeveloperGameList", {});
                    setting_dialog_view.developer_game_list = base_utility.json_to_table(data.game_list);
                end

                for key,value in ipairs(setting_dialog_view.developer_game_list)
                do
                    str, strholder = U8toCUIStr(value);
                    setting_dialog_view.game_id_combox:AppendItem(str);
                end
                setting_dialog_view.game_id_combox:SetCurSel(0);
            end
        end;
    end;

    -- 国际版增加切换语言的选项
    init_change_lanuage_setting = function()

        local data = comm_center.call_service("Svr_GetCurLanguage", {});
        if nil == setting_dialog_view.locales_list then
            setting_dialog_view.locales_list = ierd_tgp.tpf_ui.LocaleNameList:new();
        end

        local tpf_ui =
            base_utility.get_component_adapter("ITpf_ui",
                "ierd_tgp.tpf_ui.GetTPFUI();");
        if nil ~= tpf_ui then
            tpf_ui:GetLocales(setting_dialog_view.locales_list);
        end

        for index = 0, setting_dialog_view.locales_list.locale_count do
            local name = setting_dialog_view.locales_list.locales[index].friendly_name;
            local str, strholder = U8toCUIStr(name);
            setting_dialog_view.select_lanuage_combox:AppendItem(str);
        end

        --fixme
        local cur_sel = 0;
        if data["language"] == 1 then
            cur_sel = 1;
        elseif data["language"] == 2 then
            cur_sel = 2;
        else
            cur_sel = 0;
        end
        setting_dialog_view.select_lanuage_combox:SetCurSel(cur_sel);
    end;


    need_show_busy_tips = function()
        local game_lib =
            base_utility.get_component_adapter("IGame_library",
                "ierd_tgp.game_library.Get_game_library_adapter();");
        local rail_host =
            base_utility.get_component_adapter("IRailHost",
                "ierd_tgp.tgp_plugin.GetRailHostAdapter();");
        local profile_is_syncing = rail_host:IsProfileSyncing();
        local is_game_installing = comm_center.call_service("Svr_IsGameInstalling", {});
        
        local webgame_browser_running = main_menue_model.is_webgame_browser_running();
        local has_game_is_running_data = comm_center.call_service("SvrGetHasGameRunning", {});
        local has_game_is_running = false;
        if nil ~= has_game_is_running_data and has_game_is_running_data.has_game_running == 1 then
            has_game_is_running = true;
        end

        if true == is_game_installing.is_game_installing or
           true == has_game_is_running or
           webgame_browser_running or
           profile_is_syncing
           then
               return true;
        else
            return false;
        end;
    end;

    -- 海外版或者开发者版本 系统设置语言 发生变化
    deal_lanuage_change = function(ptr)
        bRet = false;

        if ptr == nil or ptr["language"] == nil then
            return bRet;
        end;

        local index = ptr["language"];
        local data = comm_center.call_service("Svr_GetCurLanguage", {});

        if data ~= nil and data["language"] ~= nil and data["language"] ~= index then

            local tip_desc = LoadStr("LANGUAGE_SET_RESTART_TIP");
            local ok_txt = LoadStr("LANGUAGE_SET_RESTART");
            local cancel_txt = LoadStr("FRAME_BOTTOM_CANCEL");
            local is_busy = false;

            if setting_dialog_view.need_show_busy_tips() then
                local is_game_installing = comm_center.call_service("Svr_IsGameInstalling", {});

                local game_lib =
                base_utility.get_component_adapter("IGame_library",
                "ierd_tgp.game_library.Get_game_library_adapter();");
                local rail_host =
                    base_utility.get_component_adapter("IRailHost",
                    "ierd_tgp.tgp_plugin.GetRailHostAdapter();");
                local profile_is_syncing = rail_host:IsProfileSyncing();

                tip_desc = LoadStr("EXIT_ACC_DESC");
                if profile_is_syncing then
                       tip_desc = LoadStr("EXIT_PROFILE_SYNC_DESC");
                elseif true == is_game_installing.is_game_installing then
                    tip_desc = LoadStr("EXIT_GAME_INSTALLING_DESC");
                elseif game_lib:AnyAppStoreGameRunning() or game_lib:AnyCloudGameRunning() then
                    tip_desc = LoadStr("EXIT_GAME_RUNNING_DESC");
                end;
            
                cancel_txt = LoadStr("EXIT_TIP_RETURN");
                ok_txt = LoadStr("EXIT_TIP_EXIT");
                local webgame_browser_running = main_menue_model.is_webgame_browser_running();
                if webgame_browser_running then
                    tip_desc = LoadStr("EXIT_WEBGAME_RUNNING_DESC");
                    cancel_txt = LoadStr("EXIT_BUTTON_CANCEL");
                    ok_txt = LoadStr("EXIT_BUTTON_QUIT");
                end;

                is_busy = true;
            end

            local restart_wegame_title = LoadStr("POP_TIPS_TIPS");
            if restart_wegame_title == nil then
                restart_wegame_title = "";
            end
            local tipParam =
            {
                position = "center",
                title = "",
                width = 350,
                height = 230,
                title= restart_wegame_title,
                titleIcon = "",
                icon = "",
                tipsIcon = "",
                descTitle = "",
                desc = tip_desc,
                okBtn = 
                {
                    visible = "true",
                    text = ok_txt,
                    handle = function()
                            data["language"] = index;
                            comm_center.call_service("Svr_SetLanguage", data);
                            poptips_control.close_tips();
                            if is_busy == true then
                                   comm_center.call_service("Svr_KillInstallProc", {});
                                local gamelib =
                                    base_utility.get_component_adapter("IGame_library",
                                    "ierd_tgp.game_library.Get_game_library_adapter();");
                                gamelib:KillAllAppStoreGames();
                            end;
                            comm_center.call_service("i_svr_save_main_wnd_pos", {});
                            comm_center.call_service("Svr_RestartWG", {});
                    end
                },
                cancelBtn = 
                {
                    visible = "true",
                    text = cancel_txt,
                    handle = function()
                    end
                }
            }
            bRet = true;
            poptips_control.show_tips(tipParam);
        end
        return bRet;
    end;


    -- 设置滚动条控件高度
    set_dialog_height = function ()
        -- 包含滚动条,需要设置高度
        -- 设置 Ctn_Normal 控件高度
        local ctn_normal_id = ui_utility.get_ctrl_id_by_path(
            setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewNormalTab\\Ctn_Normal");
        local ctnNormalHeight = 975;
        if base_utility.is_type_of_oversea_ver() then
            ctnNormalHeight = 726;
        end

        if setting_dialog_model.vendor == "huawei" or setting_dialog_model.vendor == "xiaomi" then
            ctnNormalHeight = ctnNormalHeight + 76;
        end

        --fixme by matrix  需要判断国际版
        if setting_dialog_view.is_dev_client == true then
            ctnNormalHeight = ctnNormalHeight + 10;
            if not base_utility.is_type_of_oversea_ver() then
                ctnNormalHeight = ctnNormalHeight + 72;
            end
        end
        --end
        
        ui_utility.setproperty_by_id(ctn_normal_id, "Height", ctnNormalHeight);
    end;

    -- 静默升级被勾选弹窗提示
    check_unset_silent_update_show_tips = function()
        -- 关闭静默升级会弹出提示
        if 1 ~= setting_dialog_view.is_netbar then
            if nil ~= setting_dialog_view.open_wegame_silent_update_checkbox then 
                if setting_dialog_view.open_wegame_silent_update_checkbox:IsChecked() == TRUE then
                    if setting_dialog_view.open_wegame_silent_update_warning_tips_show then
                        setting_dialog_view.open_wegame_silent_update_warning_tips:Show(FALSE);
                        setting_dialog_view.open_wegame_silent_update_warning_tips_show = false;
                    end
                else
                    if not setting_dialog_view.open_wegame_silent_update_warning_tips_show then
                        setting_dialog_view.open_wegame_silent_update_warning_tips:Show(TRUE);
                        setting_dialog_view.open_wegame_silent_update_warning_tips_show = true;
                    end
                end
            end
        end
    end;

    get_game_download_setting_control = function()
        if nil ~= setting_dialog_view.dialog_ptr then
            setting_dialog_view.download_path_edit = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Et_downloadPath");
            

            setting_dialog_view.tips_for_download_dir = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\ST_SpaceTipsForDownload");
            
            setting_dialog_view.install_path_mgr_cnt = 
                ui_utility.get_ctrl_ptr_by_path(setting_dialog_view.dialog_id, 
                "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\CtnInstallPathMgr");
                
            setting_dialog_view.install_path_1 = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.install_path_mgr_cnt:GetControlID(), "InstallPath1");
            setting_dialog_view.install_path_2 = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.install_path_mgr_cnt:GetControlID(), "InstallPath2");
            setting_dialog_view.install_path_3 = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.install_path_mgr_cnt:GetControlID(), "InstallPath3");

            setting_dialog_view.install_path_space_1 = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.install_path_mgr_cnt:GetControlID(), "InstallPathSpaceTips1");
            setting_dialog_view.install_path_space_2 = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.install_path_mgr_cnt:GetControlID(), "InstallPathSpaceTips2");
            setting_dialog_view.install_path_space_3 = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.install_path_mgr_cnt:GetControlID(), "InstallPathSpaceTips3");
            
            setting_dialog_view.install_path_count = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.install_path_mgr_cnt:GetControlID(), "InstallPathCount");

            setting_dialog_view.auto_download_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Cbx_AutoDownload");  


            local router_download_checkbox_id = ui_utility.get_ctrl_id_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Cbx_RouterDownload");
            setting_dialog_view.router_download_checkbox = ui_utility.get_ctrl_ptr_by_id(
                router_download_checkbox_id);  
            
            if setting_dialog_model.vendor == "xiaomi" then
                ui_utility.setproperty_by_id(router_download_checkbox_id, "Caption", LoadStr("GAMEDOWNLOAD_MODEL_XIAOMI"));
            elseif setting_dialog_model.vendor == "huawei" then
                ui_utility.setproperty_by_id(router_download_checkbox_id, "Caption", LoadStr("GAMEDOWNLOAD_MODEL_HUAWEI"));
            else
                setting_dialog_view.router_download_checkbox:Show(FALSE);
            end;

            setting_dialog_view.no_speed_limit_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Cbx_NoSpeedLimit"); 
             
            setting_dialog_view.have_speed_limit_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Cbx_SpeedLimit"); 
            
            setting_dialog_view.speed_input_edit = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Et_SpeedEdit"); 
            
            --checkbox group
            setting_dialog_view.save_delete_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Cbx_SaveDel"); 
            
            setting_dialog_view.save_7days_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Cbx_Save7Days"); 
            
            setting_dialog_view.save_forever_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Cbx_SaveEver"); 

            setting_dialog_view.after_buy_game_oper_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Cbx_AfterBuyGame");

            setting_dialog_view.subscribe_after_open_download_checkbox = ui_utility.get_ctrl_ptr_by_path(
                setting_dialog_view.dialog_id, "tab_ctn\\OverlapCtnTab\\ScrollViewGameTab\\Ctn_Game\\Cbx_SubscribeAferOpenDownload");

        end;
    end;

    update_video_subscribe_cfg = function()
        local has_change = false;
        if setting_dialog_view ~= nil then
            if setting_dialog_view.cfg_table ~= nil and 
                setting_dialog_view.cfg_table["video_subscribe"] ~= setting_dialog_view.video_subscribe_flag then
                has_change = true;
            end;
        else
            base_utility.log("[update_video_subscribe_cfg] setting_dialog_view is nil");
            return;
        end;
        setting_dialog_view.cfg_table["video_subscribe"] = setting_dialog_view.video_subscribe_flag;
        if has_change == true and setting_dialog_view.dialog_ptr ~= nil then
            if setting_dialog_view.dialog_ptr:IsVisible() == TRUE then
                if nil ~= setting_dialog_view.video_subscribe_checkbox then
                    if setting_dialog_view.cfg_table["video_subscribe"] == 1 then
                        setting_dialog_view.video_subscribe_checkbox:SetChecked(TRUE);
                    else
                        setting_dialog_view.video_subscribe_checkbox:SetChecked(FALSE);
                    end;
                end;
            end;
        end
    end;

    update_live_subscribe_cfg = function()
        local has_change = false;
        if setting_dialog_view ~= nil then
            if setting_dialog_view.cfg_table ~= nil and 
                setting_dialog_view.cfg_table["anchor_subscribe"] ~= setting_dialog_view.anchor_subscribe_flag then
                has_change = true;
            end;
        else
            base_utility.log("[update_live_subscribe_cfg] setting_dialog_view is nil");
            return;
        end;
        setting_dialog_view.cfg_table["anchor_subscribe"] = setting_dialog_view.anchor_subscribe_flag;
        if has_change == true and setting_dialog_view.dialog_ptr ~= nil then
            if setting_dialog_view.dialog_ptr:IsVisible() == TRUE then
                if nil ~= setting_dialog_view.anchor_subscribe_checkbox then
                    if setting_dialog_view.cfg_table["anchor_subscribe"] == 1 then
                        setting_dialog_view.anchor_subscribe_checkbox:SetChecked(TRUE);
                    else
                        setting_dialog_view.anchor_subscribe_checkbox:SetChecked(FALSE);
                    end;
                end;
            end;
        end;
    end;

    update_hotkey_cfg = function(hotkey)
        setting_dialog_view.cfg_table["game_screenshot_hotkey"] = hotkey;
        if setting_dialog_view == nil or setting_dialog_view.dialog_ptr == nil then
            return;
        end;
        if setting_dialog_view.dialog_ptr:IsVisible() ~= TRUE then
            return;
        end;
        if nil ~= setting_dialog_view.app_inner_screenshot_combobox then
            local str_hotkey_1, strHolder = U8toCUIStr(LoadStr("APP_INNER_SCREENSHOT_HOTKEY_1"));
            local str_hotkey_2, strHolder = U8toCUIStr(LoadStr("APP_INNER_SCREENSHOT_HOTKEY_2"));
            local str_hotkey_3, strHolder = U8toCUIStr(LoadStr("APP_INNER_SCREENSHOT_HOTKEY_3"));
            local str_hotkey_4, strHolder = U8toCUIStr(LoadStr("APP_INNER_SCREENSHOT_HOTKEY_4"));
            local hot_key_str_list = {str_hotkey_1, str_hotkey_2, str_hotkey_3, str_hotkey_4};
            local key_cfg_str = setting_dialog_view.cfg_table["game_screenshot_hotkey"];
            if key_cfg_str ~= nil and cfg_key ~= "" then
                for k,v in pairs(setting_dialog_view.screenshot_cfg_vlaue_list) do
                    if v == key_cfg_str then
                        setting_dialog_view.app_inner_screenshot_combobox:SetSelString(
                            hot_key_str_list[k]);
                            return;
                    end
                end
                local str_hotkey_empty, strHolder = U8toCUIStr("");
                setting_dialog_view.app_inner_screenshot_combobox:SetSelString(str_hotkey_empty);
            else
                setting_dialog_view.app_inner_screenshot_combobox:SetSelString(str_hotkey_1);
            end
        end;
    end;
    
    lost_focus = function(uilib, dwControlID, dwNewControlID)
        if  nil ~= setting_dialog_view.game_streaming_password_edit and
            nil ~= setting_dialog_view.game_streaming_password_checkbox and
            nil ~= setting_dialog_view.game_streaming_password_len_limit_tips and
            setting_dialog_view.game_streaming_password_checkbox:IsChecked() == TRUE and
            nil ~= dwControlID and
            dwControlID == setting_dialog_view.game_streaming_password_edit:GetControlID() then
            local password_text = setting_dialog_view.game_streaming_password_edit:GetText();
            local u8str = CUIStrtoU8(password_text);
            local text_len = string.len(u8str);
            if (text_len ~= 6) then
                setting_dialog_view.game_streaming_password_len_limit_tips:Show(TRUE);
            else 
                setting_dialog_view.game_streaming_password_len_limit_tips:Show(FALSE);
            end;
        end;
    end;

    on_normal_sb_thumb_pos_change = function (uilib, ctrl_id, sb_type, info)
        if nil ~= setting_dialog_view.select_lanuage_combox then
            local listbox_ctrl = setting_dialog_view.select_lanuage_combox:GetListBox();
            local ptr = tolua.cast(listbox_ctrl, "Tenio::IControl");
            if nil ~= ptr and TRUE == ptr:IsVisible() then
                ptr:Show(FALSE);
            end
        end
        if nil ~= setting_dialog_view.app_inner_screenshot_combobox then
            local listbox_ctrl = setting_dialog_view.app_inner_screenshot_combobox:GetListBox();
            local ptr = tolua.cast(listbox_ctrl, "Tenio::IControl");
            if nil ~= ptr and TRUE == ptr:IsVisible() then
                ptr:Show(FALSE);
            end
        end
    end;

    click_clean_page_cache_btn = function(data)
        local desc_txt = LoadStr("CLEAN_PAGECACHE_DESCRIPTION");
        local clean_cache_param = {
            position = 'center',
            title = LoadStr("POP_TIPS_TIPS"),
            width = 480,
            height = 230,
            titleIcon = "",
            icon = "",
            tipsIcon = poptips_icons.kWarning,
            descTitle = "",
            desc = desc_txt,
            modal = false,
            cancelBtn = {
                visible = "true",
                text = LoadStr("CLEAN_PAGECACHE_LATER"),
                handle = function()
                    local file_path = base_utility.get_work_path() .. "\\clean_cache_flag.dat";
                    local file_obj = ierd_tgp.common.LuaFileObject:new();
                    if nil ~= file_obj then
                        if file_obj:open(file_path, "w") then
                            file_obj:close();
                        end
                        file_obj:delete();
                    end
                end;
            },
            okBtn = {
                close_win = true,
                visible = "true";
                text = LoadStr("CLEAN_PAGECACHE_RESTART"),
                handle = function()
                    local file_path = base_utility.get_work_path() .. "\\clean_cache_flag.dat";
                    local file_obj = ierd_tgp.common.LuaFileObject:new();
                    if nil ~= file_obj then
                        if file_obj:open(file_path, "w") then
                            file_obj:close();
                        end
                        file_obj:delete();
                    end
                    local   pLoginMgr = base_utility.get_component_adapter("ILogin_mgr",
                            "ierd_tgp.login_mgr.GetLoginMgr();");
                    if nil ~= pLoginMgr then
                        pLoginMgr:RestartTGP();
                    end;
                end;
            },
            close_means_cancel = false,
        };
        ui_utility.show_tips(clean_cache_param);
    end;
    
     --确定按钮执行
    game_linker_click = function(uilib, dwClickId)
       local   pPluginMgr = base_utility.get_component_adapter("IPlugin_mgr",
                    "ierd_tgp.tgp_plugin.GetPluginMgrModule();");
        base_utility.log("[game_linker_click] pPluginMgr");
        if nil ~= pPluginMgr then
            base_utility.log("[game_linker_click] pPluginMgr not null");
            pPluginMgr:OnShowGameLinkerTab();
        end;
    end;

    update_install_path_setting_ui = function(path_data)
        if nil == setting_dialog_view.dialog_ptr then
            return;
        end
        if path_data ~= nil and path_data ~= "" then
            local path_list = path_data;
            if path_list == nil then
                base_utility.log(
                    "[game_linker_click]update_install_path_setting_ui path_list is empty");
                return;
            end
            setting_dialog_view.install_path_1:Show(FALSE);
            setting_dialog_view.install_path_space_1:Show(FALSE);
            setting_dialog_view.install_path_2:Show(FALSE);
            setting_dialog_view.install_path_space_2:Show(FALSE);
            setting_dialog_view.install_path_3:Show(FALSE);
            setting_dialog_view.install_path_space_3:Show(FALSE);
            local path_count = #path_list;
            for index = 1, #(path_list) do
                local node = path_list[index];
                local path_ui = node["path"];
                if index == 1 then
                    -- 默认路径
                    --setting_dialog_view.install_path_1:SetText(path_ui);
                    ui_utility.setproperty_by_id(
                        setting_dialog_view.install_path_1:GetControlID(), "Caption", path_ui);
                    ui_utility.setproperty_by_id(
                        setting_dialog_view.install_path_1:GetControlID(), "TextTip", path_ui);
                    local install_path_space_text = 
                        setting_dialog_view.get_install_space_tips_text(node["free_space_kb"]);
                    setting_dialog_view.install_path_space_1:SetText(install_path_space_text);
                    
                    setting_dialog_view.install_path_1:Show(TRUE);
                    setting_dialog_view.install_path_space_1:Show(TRUE);
                elseif index == 2 then
                    ui_utility.setproperty_by_id(
                        setting_dialog_view.install_path_2:GetControlID(), "Caption", path_ui);
                    ui_utility.setproperty_by_id(
                        setting_dialog_view.install_path_2:GetControlID(), "TextTip", path_ui);
                    local install_path_space_text = 
                        setting_dialog_view.get_install_space_tips_text(node["free_space_kb"]);
                    setting_dialog_view.install_path_space_2:SetText(install_path_space_text);

                    setting_dialog_view.install_path_2:Show(TRUE);
                    setting_dialog_view.install_path_space_2:Show(TRUE);
                elseif index == 3 then
                    --第三个路径省略显示
                    ui_utility.setproperty_by_id(
                        setting_dialog_view.install_path_3:GetControlID(), "Caption", "...");
                    ui_utility.setproperty_by_id(
                                setting_dialog_view.install_path_3:GetControlID(), "TextTip", "");
                    setting_dialog_view.install_path_3:Show(TRUE);
                    setting_dialog_view.install_path_space_3:Show(FALSE);
                end
            end

            local count_str = "";
            if path_count > 1 then
                count_str = U8toCUIStr(
                        string.format(LoadStr("INSTALL_PATH_MGR_COUNT_TIPS"), path_count));
            else
                count_str = U8toCUIStr(
                        string.format(LoadStr("INSTALL_PATH_MGR_COUNT_TIPS_SINGLE"), path_count));
            end;

            setting_dialog_view.install_path_count:SetText(count_str);
        end
    end;

    get_install_space_tips_text = function(free_space)
        local tips_text="";
        local default_text, holder = U8toCUIStr("");
        tips_text = default_text;
        if type(free_space) == "number" then
            if (free_space < 0) then
                return tips_text;
            end
            local format_space_str;
            if (free_space >= 1024 * 1024 * 1024) then
                local free_space = free_space / (1024 * 1024 * 1024);
                format_space_str = tostring(math.floor(free_space*10)/10) .. "TB";
            elseif (free_space >= 1024 * 1024) then
                local free_space = free_space / (1024 * 1024);
                --format_space_str = string.format("%.2fGB", free_space); --format会四舍五入
                format_space_str = tostring(math.floor(free_space*10)/10) .. "GB";
            elseif (free_space >= 1024) then
                local free_space = free_space / 1024;
                format_space_str = tostring(math.floor(free_space*10)/10) .. "MB";
            else
                format_space_str = string.format("%dKB", free_space);
            end
            local ui_str, holder = U8toCUIStr(
                string.format(LoadStr("INSTALL_PATH_MGR_SPACE_TIPS"), format_space_str));
            tips_text = ui_str;
        end
        return tips_text;
    end;

    refresh_subscribe_after_open_dl_ui = function()
        if nil ~= setting_dialog_view.subscribe_after_open_download_checkbox then
            setting_dialog_view.inner_log("refresh_subscribe_after_open_dl_ui");
            if setting_dialog_model.subscribe_after_open_download == 1 then
                setting_dialog_view.subscribe_after_open_download_checkbox:SetChecked(TRUE);
                setting_dialog_view.qos_track_settings["subscribe_after_open_download"] = 1;
            else 
                setting_dialog_view.subscribe_after_open_download_checkbox:SetChecked(FALSE);
            end
        end
    end;

    increase_game_duration = function(uilib, dwClickId)
        setting_dialog_view.operate_game_duration(1);
    end;

    reset_game_duration = function(uilib, dwClickId)
        setting_dialog_view.operate_game_duration(2);
    end;

    query_game_duration = function(uilib, dwClickId)
        setting_dialog_view.operate_game_duration(3);
    end;

    operate_game_duration = function(op_type)
        local ui_str, holder = U8toCUIStr("");
        setting_dialog_view.game_duration_tips:SetText(ui_str);

        local cur_sel = setting_dialog_view.game_id_combox:GetCurSel();
        local game_id = setting_dialog_view.developer_game_list[cur_sel + 1];
        -- local duration_type = setting_dialog_view.select_game_duration_combox:GetCurSel() + 1;
        local duration_type = 2;
        setting_dialog_control.operate_game_duration(game_id, duration_type, op_type);
    end;

    on_operation_duration_rsp = function(data)
        if data == nil then
            return
        end
        if setting_dialog_view.game_duration_tips == nil then
            return
        end

        if data.result == 0 then
            base_utility.log("on_operation_duration_rsp, success");
            setting_dialog_view.game_duration_tips:SetTextColor(setting_dialog_view.succ_color);
        else
            base_utility.log("on_operation_duration_rsp, failed");
            setting_dialog_view.game_duration_tips:SetTextColor(setting_dialog_view.error_color);
        end
        local ui_str, holder = U8toCUIStr(data.msg);
        setting_dialog_view.game_duration_tips:SetText(ui_str);
    end;
};

setting_dialog_view.init();
